/**
 * waterQuality vuex
 */
import posts from '@/plugins/request'
// initial state
const state = {
  transportList: {
    table: [],
    total: 0
  }
}
// getters
const getters = {
  getTransportList: state => state.transportList.table,
  getTransportTotalPage: state => state.transportList.total,
}
// actions

const actions = {
  async getTransportList({ commit }, param) {
    let result = await posts.getTransportList(param)
    let tableList = result.data
    for(let i = 0; i < tableList.length; i++) {
      let imgList = tableList[i].photo.split(',')
      imgList.pop()
      tableList[i].imgList = imgList
    }
    commit('changeTransportList', result)
  },
  async insertTransportInput({commit}, formdata) {
    let result = await posts.insertTransportInput(formdata)
    return result
  },
  async exportTransportExcel({commit}, param) {
    await posts.exportTransportExcel(param)
  },
}

// mutations
const mutations = {
  changeTransportList(state, data) {
    state.transportList.table = data.data
    state.transportList.total = data.totalpage
  }
}


export default {
  state,
  getters,
  actions,
  mutations
}